package co.edu.usbcali.prototipobeta.modelo.dto;

import co.edu.usbcali.prototipobeta.modelo.CarnetVacunas;
import co.edu.usbcali.prototipobeta.presentation.backingBeans.CarnetVacunasView;

import java.io.Serializable;

import java.util.Date;

import javax.faces.event.ActionEvent;


/**
*
*
* @author Zathura Code Generator http://code.google.com/p/zathura
*
*/
public class CarnetVacunasDTO implements Serializable {
    private static final long serialVersionUID = 1L;
    private String bebeId_Bebe;
    private String vacId_Vacuna;
    private String carId;
    private Date carFechaaplicacion;
    private boolean rowSelected = false;
    private CarnetVacunasView carnetVacunasView;
    private CarnetVacunas carnetVacunas;

    public CarnetVacunas getCarnetVacunas() {
        return carnetVacunas;
    }

    public String listener_update(ActionEvent e) {
        try {
            carnetVacunasView.action_modifyWitDTO(((carFechaaplicacion == null) ||
                carFechaaplicacion.equals("")) ? null : carFechaaplicacion,
                ((carId == null) || carId.equals("")) ? null : new Long(carId),
                ((bebeId_Bebe == null) || bebeId_Bebe.equals("")) ? null
                                                                  : new Long(
                    bebeId_Bebe),
                ((vacId_Vacuna == null) || vacId_Vacuna.equals("")) ? null
                                                                    : new Long(
                    vacId_Vacuna));
            rowSelected = !rowSelected;
        } catch (Exception ex) {
            return "";
        }

        return "";
    }

    public void listener_cancel(ActionEvent e) {
        carId = carnetVacunas.getCarId().toString();
        carFechaaplicacion = carnetVacunas.getCarFechaaplicacion();
        bebeId_Bebe = (carnetVacunas.getBebe().getBebeId() != null)
            ? carnetVacunas.getBebe().getBebeId().toString() : null;
        vacId_Vacuna = (carnetVacunas.getVacuna().getVacId() != null)
            ? carnetVacunas.getVacuna().getVacId().toString() : null;
        rowSelected = !rowSelected;
    }

    /**
    * <p>Bound to commandLink actionListener in the ui that renders/unrenders
        * the Object details for editing.</p>
        */
    public void toggleSelected(ActionEvent e) {
        carId = carnetVacunas.getCarId().toString();
        carFechaaplicacion = carnetVacunas.getCarFechaaplicacion();
        bebeId_Bebe = (carnetVacunas.getBebe().getBebeId() != null)
            ? carnetVacunas.getBebe().getBebeId().toString() : null;
        vacId_Vacuna = (carnetVacunas.getVacuna().getVacId() != null)
            ? carnetVacunas.getVacuna().getVacId().toString() : null;
        rowSelected = !rowSelected;
    }

    public void setCarnetVacunas(CarnetVacunas carnetVacunas) {
        this.carnetVacunas = carnetVacunas;
    }

    public CarnetVacunasView getCarnetVacunasView() {
        return carnetVacunasView;
    }

    public void setCarnetVacunasView(CarnetVacunasView carnetVacunasView) {
        this.carnetVacunasView = carnetVacunasView;
    }

    public String getBebeId_Bebe() {
        return bebeId_Bebe;
    }

    public void setBebeId_Bebe(String bebeId_Bebe) {
        this.bebeId_Bebe = bebeId_Bebe;
    }

    public String getVacId_Vacuna() {
        return vacId_Vacuna;
    }

    public void setVacId_Vacuna(String vacId_Vacuna) {
        this.vacId_Vacuna = vacId_Vacuna;
    }

    public Date getCarFechaaplicacion() {
        return carFechaaplicacion;
    }

    public void setCarFechaaplicacion(Date carFechaaplicacion) {
        this.carFechaaplicacion = carFechaaplicacion;
    }

    public String getCarId() {
        return carId;
    }

    public void setCarId(String carId) {
        this.carId = carId;
    }

    public boolean isRowSelected() {
        return rowSelected;
    }

    public void setRowSelected(boolean rowSelected) {
        this.rowSelected = rowSelected;
    }
}
